package com.sanmubird.mywebframework.indicator.domain.service;

import com.alibaba.fastjson.JSONObject;
import com.sanmubird.mywebframework.indicator.domain.executor.IndicatorExecutorProvider;
import com.sanmubird.mywebframework.indicator.domain.model.Indicator;
import com.sanmubird.mywebframework.indicator.domain.model.IndicatorExecutor;
import org.springframework.stereotype.Service;


/**
 * @author sam
 */
@Service
public class IndicatorExecutorService {

    private final IndicatorExecutorProvider indicatorExecutorProvider;

    public IndicatorExecutorService(IndicatorExecutorProvider indicatorExecutorProvider) {
        this.indicatorExecutorProvider = indicatorExecutorProvider;
    }

    public Object internalExecute(Indicator indicator, JSONObject queryParams) {
        IndicatorExecutor executor = indicatorExecutorProvider.acquire(indicator.getType());
        return executor.execute(indicator, queryParams);
    }

}
